package us.mooresr.geartrack.client.events;

import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.EventHandler;
import us.mooresr.geartrack.shared.model.Item;
import com.google.gwt.event.shared.HasHandlers;

public class ItemDeletedEvent extends
		GwtEvent<ItemDeletedEvent.ItemDeletedHandler> {

	public static Type<ItemDeletedHandler> TYPE = new Type<ItemDeletedHandler>();
	private Item item;

	public interface ItemDeletedHandler extends EventHandler {
		void onItemDeleted(ItemDeletedEvent event);
	}

	public ItemDeletedEvent(Item item) {
		this.item = item;
	}

	public Item getItem() {
		return item;
	}

	@Override
	protected void dispatch(ItemDeletedHandler handler) {
		handler.onItemDeleted(this);
	}

	@Override
	public Type<ItemDeletedHandler> getAssociatedType() {
		return TYPE;
	}

	public static Type<ItemDeletedHandler> getType() {
		return TYPE;
	}

	public static void fire(HasHandlers source, Item item) {
		source.fireEvent(new ItemDeletedEvent(item));
	}
}
